Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <body> <p>This is a p element</p> <p>This is also a p element.</p> <p>This is also a p element - Click the button to change the background color of all p elements in this document.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.getElementsByTagName("P"); var i; for (i = 0; i < x.length; i++) { x[i].style.backgroundColor = "red"; } } </script> </body> <!-- Mirrored from www.w3schools.com/jsref/tryit.asp?filename=tryjsref_document_getelementsbytagname3 by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:10:51 GMT --> </html>
Result:
Try it Yourself - © w3schools.com